package com.study.samsung.Control.htControl;

import com.study.samsung.Service.htService.QuantityService;
import com.study.samsung.Utils.BaseServlet;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.Date;

@WebServlet("/htindex")
public class IndexServlet extends BaseServlet {
    QuantityService service = new QuantityService();
    @Override
    public String excute(HttpServletRequest request, HttpServletResponse response) throws Exception {
        Object obj = session.getAttribute("admin");
        if (obj==null){
            return "f:htjsp/login";
        }else {
            Integer usersum = service.selectAllUser();
            Integer nigger = service.selectAllBlackMan();
            Integer goodnum = service.selectAllGood();
            Integer adminsun = service.selectAllAdmin();
            Date date  = new Date();
            session.setAttribute("date",date.toString());
            session.setAttribute("usersum",usersum);
            session.setAttribute("nigger",nigger);
            session.setAttribute("goodnum",goodnum);
            session.setAttribute("adminsun",adminsun);
            return "f:htjsp/index";
        }

    }

}
